/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrmFacturas.java
 *
 * Created on 20-oct-2011, 10:06:20
 */
package Formularios.forms;

import java.util.Date;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import tsl_nacha.dominio.Articulos;
import tsl_nacha.dominio.Clientes;
import tsl_nacha.dominio.Cuentas;
import tsl_nacha.dominio.Facturas;
import tsl_nacha.dominio.Impresora;
import tsl_nacha.dominio.Lineas;
import tsl_nacha.dominio.Utilitaria;
import tsl_nacha.gestoras.GestArticulos;
import tsl_nacha.gestoras.GestClientes;
import tsl_nacha.gestoras.GestCuentas;
import tsl_nacha.gestoras.GestFacturas;

/**
 *
 * @author Luis
 */
public class FrmFacturas extends javax.swing.JInternalFrame {

    Facturas Factura = null;

    /** Creates new form FrmFacturas */
    public FrmFacturas() {
        initComponents();
//        ((javax.swing.plaf.basic.BasicInternalFrameUI) this.getUI()).setNorthPane(null);
//        this.txtcodigo.setText(String.valueOf(GestFacturas.getInstance().devolverUltimoNum()));
//        Factura = new Facturas();
//        DefaultComboBoxModel modelo = (DefaultComboBoxModel) this.cboxcliente.getModel();
//        Utilitaria.listarClienteComboConCuenta(modelo);
//        Date hoy = new Date();
//        jDateChooser1.setDate(hoy);
        this.formabierto();

    }

    public final void formabierto() {
        ((javax.swing.plaf.basic.BasicInternalFrameUI) this.getUI()).setNorthPane(null);
        this.txtcodigo.setText(String.valueOf(GestFacturas.getInstance().devolverUltimoNum()));
        Factura = new Facturas();
        DefaultComboBoxModel modelo = (DefaultComboBoxModel) this.cboxcliente.getModel();
        Utilitaria.listarClienteComboConCuenta(modelo);
        this.cboxcliente.setSelectedItem(null);
        Date hoy = new Date();
        jDateChooser1.setDate(hoy);
        this.txtarticulo.setName("cliente");
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtcodigo = new javax.swing.JTextField();
        txtcantidad = new javax.swing.JTextField();
        txtarticulo = new javax.swing.JTextField();
        txttotal = new javax.swing.JTextField();
        btnEliminar = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jPanel1 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jDateChooser1 = new com.toedter.calendar.JDateChooser();
        jLabel8 = new javax.swing.JLabel();
        txtdescripcion = new javax.swing.JTextField();
        btnAgregar1 = new javax.swing.JButton();
        txtsubtotal = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        txtiva = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        cboxcliente = new javax.swing.JComboBox();
        jButton2 = new javax.swing.JButton();
        btnagregar = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        setBorder(null);
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(698, 581));
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameClosed(evt);
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel1.setText("Numero :");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 80, -1, -1));

        jLabel2.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel2.setText("Descripcion :");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 170, -1, -1));

        jLabel3.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel3.setText("Cantidad :");
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 140, -1, -1));

        jLabel4.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel4.setText("Articulo :");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 110, -1, -1));

        jLabel5.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel5.setText("Subtotal :");
        getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 400, -1, -1));

        txtcodigo.setEditable(false);
        txtcodigo.setFont(new java.awt.Font("Verdana", 0, 10));
        getContentPane().add(txtcodigo, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 80, 120, -1));

        txtcantidad.setFont(new java.awt.Font("Verdana", 0, 10));
        getContentPane().add(txtcantidad, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 140, 170, -1));

        txtarticulo.setFont(new java.awt.Font("Verdana", 0, 10));
        txtarticulo.setText("0");
        txtarticulo.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                txtarticuloCaretUpdate(evt);
            }
        });
        txtarticulo.addInputMethodListener(new java.awt.event.InputMethodListener() {
            public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
            }
            public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
                txtarticuloInputMethodTextChanged(evt);
            }
        });
        txtarticulo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtarticuloKeyTyped(evt);
            }
        });
        getContentPane().add(txtarticulo, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 110, 170, -1));

        txttotal.setEditable(false);
        txttotal.setFont(new java.awt.Font("Verdana", 1, 11));
        txttotal.setForeground(new java.awt.Color(255, 0, 0));
        getContentPane().add(txttotal, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 460, 170, -1));

        btnEliminar.setFont(new java.awt.Font("Verdana", 0, 10));
        btnEliminar.setText("Eliminar");
        btnEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarActionPerformed(evt);
            }
        });
        getContentPane().add(btnEliminar, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 510, 80, 40));

        jLabel7.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel7.setText(" Total :");
        getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 460, -1, 20));

        jTable2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Numero", "Articulo", "Cantidad", "Total"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.Integer.class, java.lang.Double.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable2MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(jTable2);

        getContentPane().add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 200, 670, 190));

        jPanel1.setBackground(new java.awt.Color(153, 180, 209));
        jPanel1.setPreferredSize(new java.awt.Dimension(698, 71));

        jLabel6.setBackground(new java.awt.Color(51, 255, 51));
        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 48));
        jLabel6.setText("Factura");
        jLabel6.setToolTipText("");

        jLabel8.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel8.setText("Fecha:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 301, Short.MAX_VALUE)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jDateChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jDateChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 698, 71));

        txtdescripcion.setEditable(false);
        txtdescripcion.setFont(new java.awt.Font("Tahoma", 1, 11));
        txtdescripcion.setForeground(new java.awt.Color(255, 0, 0));
        getContentPane().add(txtdescripcion, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 170, 170, -1));

        btnAgregar1.setFont(new java.awt.Font("Verdana", 0, 10));
        btnAgregar1.setText("Agregar");
        btnAgregar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregar1ActionPerformed(evt);
            }
        });
        getContentPane().add(btnAgregar1, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 510, 80, 40));

        txtsubtotal.setEditable(false);
        txtsubtotal.setFont(new java.awt.Font("Verdana", 1, 11));
        getContentPane().add(txtsubtotal, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 400, 170, -1));

        jLabel9.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel9.setText("Iva % :");
        getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 430, -1, -1));

        txtiva.setEditable(false);
        txtiva.setFont(new java.awt.Font("Verdana", 1, 11));
        getContentPane().add(txtiva, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 430, 50, -1));

        jLabel10.setFont(new java.awt.Font("Verdana", 1, 10));
        jLabel10.setText("Cliente :");
        jLabel10.setToolTipText("");
        getContentPane().add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 80, 50, 20));

        getContentPane().add(cboxcliente, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 80, 240, -1));

        jButton2.setText("...");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 80, 20, 20));

        btnagregar.setFont(new java.awt.Font("Tahoma", 0, 10));
        btnagregar.setText(">>");
        btnagregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnagregarActionPerformed(evt);
            }
        });
        getContentPane().add(btnagregar, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 170, 50, 20));

        jButton1.setFont(new java.awt.Font("Tahoma", 0, 10));
        jButton1.setText(">>");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 110, 50, 20));

        jButton3.setText("Lista");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 110, 70, 20));

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed
    try {
        String s = String.valueOf(jTable2.getValueAt(jTable2.getSelectedRow(), 0));
        int numero = Integer.parseInt(s);
        if (Factura.eliminarLineaFactura(numero)) {
            DefaultTableModel modelo = (DefaultTableModel) this.jTable2.getModel();
            Utilitaria.listarLineasFactura(modelo, Factura);
            this.txtsubtotal.setText(String.valueOf(Factura.getfSubTotal()));
            this.txtiva.setText(String.valueOf(Factura.getfIva()));
            this.txttotal.setText(String.valueOf(Factura.getfTotal()));
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(rootPane, "Seleccione una linea para luego poder eliminarla");
    }
}//GEN-LAST:event_btnEliminarActionPerformed

private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked
    // TODO add your handling code here:
    //txtfingreso.sets
}//GEN-LAST:event_jTable2MouseClicked

private void btnAgregar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregar1ActionPerformed
// TODO add your handling code here:
    try {
        if (Factura.getmColLineas().isEmpty()) {
            JOptionPane.showMessageDialog(rootPane, "Una factura debe de contener al menos una linea");
        } else {
            Clientes c2 = (Clientes) this.cboxcliente.getSelectedItem();
            if(Factura.comprobarStock()){
                JOptionPane.showMessageDialog(rootPane, "Stock insuficiente de algun articulo, verifique");
            }else{
            if (GestCuentas.getInstance().clienteTieneCuenta((Clientes) this.cboxcliente.getSelectedItem()) && !GestClientes.getInstance().esNacha(c2)) {


                if (JOptionPane.showConfirmDialog(rootPane, "OK= A LA CUENTA / CANCEL = CONTADO", "WORA MESSAGE", JOptionPane.YES_NO_OPTION) == 0) {
                    String fecha = Utilitaria.convertirDateString(this.jDateChooser1.getDate());
                    Factura.setfFecha(fecha);
                    Factura.setfNumero(Integer.parseInt(this.txtcodigo.getText()));
                    Cuentas c = GestCuentas.getInstance().devolverCuentaPorCliente((Clientes) this.cboxcliente.getSelectedItem());
                    Factura.setObjCuenta(c);
                    if (GestFacturas.getInstance().agregarFactura(Factura)) {
                        Impresora l = new Impresora();
                        l.imprimir(Factura);
                        GestCuentas.getInstance().aumentarSaldoCuenta((Clientes) this.cboxcliente.getSelectedItem(), Factura);
                        Factura.agregarLineasBD();
                          for (Lineas l1 : Factura.devolverLineasFact()) {
                        l1.getObjArticulo().restarStock(l1.getlCantidad());
                    }
                        JOptionPane.showMessageDialog(rootPane, "Al cliente" + " " + this.cboxcliente.getSelectedItem() + " " + "se le sumaron " + " " + Factura.getfTotal() + " $" + " a la cuenta");
                    }
                } else {
                    Factura.setObjCuenta(GestCuentas.getInstance().devolverCuentaPorNumero(0));
                    String fecha = Utilitaria.convertirDateString(this.jDateChooser1.getDate());
                    Factura.setfFecha(fecha);
                    Factura.setfNumero(Integer.parseInt(this.txtcodigo.getText()));
                    if (GestFacturas.getInstance().agregarFactura(Factura)) {
                        Impresora l = new Impresora();
                        l.imprimir(Factura);
                        Factura.agregarLineasBD();
                        for (Lineas l1 : Factura.devolverLineasFact()) {
                            l1.getObjArticulo().restarStock(l1.getlCantidad());
                        }
                    }
                }
            } else {
                Factura.setObjCuenta(GestCuentas.getInstance().devolverCuentaPorNumero(0));
                String fecha = Utilitaria.convertirDateString(this.jDateChooser1.getDate());
                Factura.setfFecha(fecha);
                Factura.setfNumero(Integer.parseInt(this.txtcodigo.getText()));
                if (GestFacturas.getInstance().agregarFactura(Factura)) {
                    JOptionPane.showMessageDialog(rootPane, "Gracias por su compra");
                    Factura.agregarLineasBD();
                    Impresora l = new Impresora();
                    l.imprimir(Factura);

                    for (Lineas l1 : Factura.devolverLineasFact()) {
                        l1.getObjArticulo().restarStock(l1.getlCantidad());
                    }

                }
            }


        }
        Utilitaria.limpiarJtables((DefaultTableModel) this.jTable2.getModel());
        this.txtarticulo.setText("");
        this.txtcantidad.setText("");
        this.txtcodigo.setText("");
        this.txtdescripcion.setText("");
        this.txtiva.setText("");
        this.txtsubtotal.setText("");
        this.txttotal.setText("");

        Utilitaria.limpiarCombo((DefaultComboBoxModel) this.cboxcliente.getModel());
        this.formabierto();

    } }catch (NullPointerException e) {
        JOptionPane.showMessageDialog(rootPane, "Complete todos los datos");
    }




}//GEN-LAST:event_btnAgregar1ActionPerformed

private void txtarticuloInputMethodTextChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_txtarticuloInputMethodTextChanged
// TODO add your handling code here
}//GEN-LAST:event_txtarticuloInputMethodTextChanged

private void txtarticuloKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtarticuloKeyTyped
// TODO add your handling code here:
}//GEN-LAST:event_txtarticuloKeyTyped

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // TODO add your handling code here:
}//GEN-LAST:event_jButton2ActionPerformed

private void btnagregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnagregarActionPerformed
// TODO add your handling code here:
    try {
        Articulos objA = GestArticulos.getInstance().devolverArticuloNumero(this.txtarticulo.getText());
        if (objA.getaStock() < 1) {
            JOptionPane.showMessageDialog(rootPane, "El Stock es minimo ");
        } else {
            double totalLinea = objA.getaPrecio() * Integer.parseInt(this.txtcantidad.getText());
            Lineas objLinea = new Lineas(GestFacturas.getInstance().devolverNumeroLinea(), objA, Integer.parseInt(this.txtcantidad.getText()), totalLinea, Integer.parseInt(this.txtcodigo.getText()));
            if (Factura.agregarLinea(objLinea)) {
                DefaultTableModel modelo = (DefaultTableModel) this.jTable2.getModel();
                Utilitaria.listarLineasFactura(modelo, Factura);
//        objLinea.getObjArticulo().restarStock(objLinea.getlCantidad());
                Factura.agregarPieFactura(objLinea);
                this.txtsubtotal.setText(String.valueOf(Factura.getfSubTotal()));
                this.txtiva.setText(String.valueOf(Factura.getfIva()));
                this.txttotal.setText(String.valueOf(Factura.getfTotal()));
            } else {
                DefaultTableModel modelo = (DefaultTableModel) this.jTable2.getModel();
                Utilitaria.listarLineasFactura(modelo, Factura);
//        objLinea.getObjArticulo().restarStock(objLinea.getlCantidad());
                Factura.agregarPieFactura(objLinea);
                this.txtsubtotal.setText(String.valueOf(Factura.getfSubTotal()));
                this.txtiva.setText(String.valueOf(Factura.getfIva()));
                this.txttotal.setText(String.valueOf(Factura.getfTotal()));
            }
        }
    } catch (NumberFormatException e) {
        JOptionPane.showMessageDialog(rootPane, "Primero seleccione un Articulo y luego ingrese su cantidad / Solamente numeros");
    } catch (NullPointerException e) {
        JOptionPane.showMessageDialog(rootPane, "Primero seleccione un Articulo y luego ingrese su cantidad / Solamente numeros");
    }

}//GEN-LAST:event_btnagregarActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
    try {
        Articulos art = GestArticulos.getInstance().devolverArticuloNumero(this.txtarticulo.getText());
        this.txtdescripcion.setText(art.getaDescripcion());
    } catch (NumberFormatException e) {
        JOptionPane.showMessageDialog(rootPane, "Error 101: Formato incorrecto");
    } catch (NullPointerException e) {
        JOptionPane.showMessageDialog(rootPane, "Verifique si existe un articulo con ese codigo");
    }
}//GEN-LAST:event_jButton1ActionPerformed

    private void formInternalFrameClosed(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosed
        // TODO add your handling code here:
        System.out.println("hola");
    }//GEN-LAST:event_formInternalFrameClosed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        frmListarArticulos F = new frmListarArticulos(this);
        F.setVisible(true);
        /*frmListarArticulos  frm =  frmListarArticulos.getInstance();
        frm.show();*/
    }//GEN-LAST:event_jButton3ActionPerformed

    private void txtarticuloCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtarticuloCaretUpdate
        // TODO add your handling code here:
        try {
            Articulos art = GestArticulos.getInstance().devolverArticuloNumero(this.txtarticulo.getText());
            this.txtdescripcion.setText(art.getaDescripcion());
        } catch (NumberFormatException e) {
        } catch (NullPointerException e) {
        }


    }//GEN-LAST:event_txtarticuloCaretUpdate

    /**
     * @param args the command line arguments
     */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAgregar1;
    private javax.swing.JButton btnEliminar;
    private javax.swing.JButton btnagregar;
    private javax.swing.JComboBox cboxcliente;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private com.toedter.calendar.JDateChooser jDateChooser1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable2;
    private javax.swing.JTextField txtarticulo;
    private javax.swing.JTextField txtcantidad;
    private javax.swing.JTextField txtcodigo;
    private javax.swing.JTextField txtdescripcion;
    private javax.swing.JTextField txtiva;
    private javax.swing.JTextField txtsubtotal;
    private javax.swing.JTextField txttotal;
    // End of variables declaration//GEN-END:variables
}
